#pragma once
#include "mj.h"
#include <vector>

//冲锋责任效果
enum SPEACIAL_CHICKEN {
	DISABLE = -1,
	ABLE = 0,
	FIGHTING = 1,
	BLAME = 2
};

//鸡牌类
class Chicken
{
public:
	Chicken(int mj_val, SPEACIAL_CHICKEN speacial = DISABLE, int base = 1)
		: _seat(0)
		, _mj(mj_val)
		, _status(speacial)
		, _muli(1)
		, _base(base)
	{}
	bool operator==(const Mj& val)
	{
		return _mj == val;
	}
	//判断座位是否是特殊鸡
	SPEACIAL_CHICKEN IsSpeacial(int seat)
	{
		if (seat != _seat)return ABLE;
		return _status;
	}
	SPEACIAL_CHICKEN operator[](int seat)
	{
		if (seat != _seat)return ABLE;
		return _status;
	}
	//获取得分倍数
	int MuliNum() { return _base * _muli; }
	//处理特殊鸡
	bool HandleSpeacial(int seat, SPEACIAL_CHICKEN status)
	{
		if (_status != ABLE)return false;
		if (_seat != 0)return false;
		_seat = seat;
		_status = status;
		return true;
	}
	//提升倍数
	void operator*(int muli)
	{
		_muli *= muli;
	}
	void operator*=(int muli)
	{
		_muli = muli;
	}
	//在牌组里找有多少个该牌
	size_t GetCountFromVec(const std::vector<Mj>& vec)
	{
		size_t cnt(0);
		for (const auto& mj : vec)
		{
			cnt += (_mj == mj) ? 1 : 0;
		}
		return cnt;
	}
	void reset()
	{
		_seat = 0;
		_muli = 1;
		if (_status != DISABLE)
		{
			_status = ABLE;
		}
	}
	int						_seat;
protected:
	Mj						_mj;			//这个鸡的麻将牌
	SPEACIAL_CHICKEN		_status;
	int						_muli;
	int						_base;
};

//鸡牌组
class ChickenGroup : std::map<Mj, Chicken>
{
public:
	bool NewChicken(int mj_val, SPEACIAL_CHICKEN speacial = DISABLE, int base = 1)
	{
		Mj mj(mj_val);
		//如果这个鸡存在
		if (find(mj) != end())return false;
		//如果不存在
		insert(std::make_pair(mj,Chicken(mj_val, speacial, base)));
		return true;
	}
	Chicken& operator[](int mj_val)
	{
		return (*this)[mj_val];
	}
	void reset()
	{
		for (auto& info : *this)
		{
			info.second.reset();
		}
	}
};